package cn.loioi.web.components.beetl.format;

import org.beetl.core.Format;

import cn.loioi.multi.enums.MessageState;
import cn.loioi.multi.enums.MessageType;

public class MessageFormat implements Format {

	@Override
	public Object format(Object data, String pattern) {
		if (!(data instanceof Integer)) { return null; }
		if (pattern == null) { return data; }
		switch (pattern) {
		case "type":
			return String.valueOf(MessageType.parse((int) data));
		case "state":
			return String.valueOf(MessageState.parse((int) data));
		default:
			return "";
		}
	}

}
